package com.example.leetdemo.process;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Solution2397 {

    public int maximumRows(int[][] matrix, int numSelect) {
        Set<Integer> set = new HashSet<>();
        List<List<Integer>> list = new ArrayList<>();
        dps(set, numSelect, 0, list, matrix[0].length);
        int max = 0;
        for (int i = 0; i < list.size(); i++) {
            List<Integer> te = list.get(i);
            int count = 0;
            for (int k = 0; k < matrix.length; k++) {
                int temp = 1;
                for (int j = 0; j < matrix[k].length; j++) {
                    if (!te.contains(j) && j == 1) {
                        temp = 0;
                        break;
                    }
                }
                count += temp;
            }
            max = Math.max(max, count);
        }
        return max;
    }


    private void dps(Set<Integer> set, Integer cols, Integer k, List<List<Integer>> list, int max) {
        if (k > max) {
            return;
        }
        if (set.size() == cols) {
            List<Integer> list1 = new ArrayList<>();
            list1.addAll(set);
            list.add(list1);
        }
        set.add(k);
        dps(set, cols, k + 1, list, max);
        set.remove(k);
        dps(set, cols, k + 1, list, max);
    }

    public static void main(String[] args) {
        int[][] ints = new int[][] {
                {0,0,0},{1,0,1},{0,1,1},{0,0,1}
        };
        Solution2397 solution2397 = new Solution2397();
        System.err.println(solution2397.maximumRows(ints, 2));
    }
    public int minOperations(String[] logs) {
        int step = 0;
        for(int i = 0; i < logs.length; i++) {
            if(logs[i].equals("../")) {
                step--;
            } else if(!logs[i].equals("./")) {
                step++;
            }
        }
        return Math.max(step, 0);
    }
}
